<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>五星健康保洁</title>
    <link href="https://cdn.bootcss.com/normalize/8.0.1/normalize.min.css" rel="stylesheet">
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
    <style>
        * {
            box-sizing: border-box;
        }

        body {
            /*background-color: #EEBA92;*/
            background: #cbe8d6;
            font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, "Microsoft Yahei", "Hiragino Sans GB", "Heiti SC", "WenQuanYi Micro Hei", sans-serif;
        }

        #banner {
            width: 100%;
        }

        #form {
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            margin: 0 17px 0 17px;
            background-image: url("/static/kitchen/bg2.png");
            background-repeat: no-repeat;
            background-size: 100%;
            background-position: top center;
        }

        #title1 {
            padding-top: 20px;
            text-align: center;
            font-size: 19px;
            color: #333;
        }

        #title2 {
            text-align: center;
            font-size: 25px;
            color: #333;
            line-height: 50px;
        }

        .body {
            width: 85%;
            margin-top: 45px;
        }

        #location {
            font-size: 13px;
            color: #333;
            margin-bottom: 10px;
        }

        #input {
            width: 100%;
            padding: 0 10px;
            color: #333;
            font-size: 13px;
            background-color: #f7f7f7;
            height: 40px;
            border: 1px solid #808080;
            border-radius: 5px;
            outline: none;
        }

        #btn {
            display: flex;
            justify-content: center;
            align-items: center;
            margin-top: 16px;
            height: 40px;
            width: 100%;
            margin-bottom: 25px;
            font-size: 18px;
            background-color: #f33f3e;
            color: #fff;
            border-radius: 5px;
        }

        #left-block {
            width: 80px;
            line-height: 75px;
            text-align: center;
            background-color: #f33f3e;
            border-radius: 5px;
            color: #fff;
            font-size: 12px;
        }

        #right-block {
            flex: 1;
            display: flex;
            padding: 0 10px;
            flex-direction: column;
            justify-content: center;
        }

        #btn-block {
            border: 1px solid #f33f3e;
            color: #f33f3e;
            font-size: 13px;
            padding: 5px 10px;
            border-radius: 3px;
        }

        .loading {
            display: flex;
            justify-content: center;
            align-items: center;
            top: 60px;
            width: 90px;
            height: 80px;
            background-color: rgba(0, 0, 0, 0.7);
            border-radius: 10px;
        }

        .loading span {
            display: inline-block;
            width: 6px;
            height: 0;
            margin: 0 2px;
            border-radius: 4px;
            background: #fff;
            -webkit-animation: load 1s ease infinite;
        }

        @-webkit-keyframes load {
            0%, 100% {
                height: 20px;
            }
            50% {
                height: 40px;
            }
        }

        .loading span:nth-child(2) {
            -webkit-animation-delay: 0.2s;
        }

        .loading span:nth-child(3) {
            -webkit-animation-delay: 0.4s;
        }

        .loading span:nth-child(4) {
            -webkit-animation-delay: 0.6s;
        }

        .loading span:nth-child(5) {
            -webkit-animation-delay: 0.8s;
        }

        #modal {
            display: none;
            justify-content: center;
            align-items: center;
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            z-index: 999;
        }
    </style>
    <script>
      function submit() {
        const message = '{{message}}';
        const setting = {
          merchantNo: 'MTA0MzEwMTcyOTU1MzY3', // 商户号
          version: 'MS4wLjE=', // 版本号
          messageId: 'MDAwMDIxMg==', // 交易码
          security: 'UDc=', // 签名方法
          message: message, // 请求报文明文信息
          signature: '{{ signature }}',
          custBackFlag: '1' // 返回商户页面
        };
        window.c_plugins.merchantBridge.callPaymentControl(function (data) {
          // 下述内容为点击左上角<后执行
          alert('已调起支付控件');
          if (data.isCancelPay === '1') {
            // 客户取消了支付
          } else {
            if (data.orderStatus === '1') {
              // 支付成功的回调方法，可写返回后逻辑
            } else {
              // 支付失败的回调方法 ，可写返回后逻辑
            }
          }

        }, function (err) {
          alert(err.message || err || '网络错误，请检查网络连接');
        }, setting)
      }

      function goto() {
        wx.miniProgram.switchTab({url: '{{ redirect }}'})
      }

      function onBlur() {
        let isIOS = !!navigator.userAgent.match(/iPhone/);
        if (isIOS) {
          setTimeout(() => {
            const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
            window.scrollTo(0, Math.max(scrollHeight - 1, 0))
          }, 200)
        }
      }
    </script>
</head>
<body>
<img id="banner" src="/static/200429/bg1.png" alt="banner"/>
<div>
    <div id="form">
        <div id="title1">诚邀您体验</div>
        <div id="title2">五星健康保洁</div>
        <div id="init" class="body">
            <div id="location">所在城市：<span style="color: #FC534C">上海</span></div>
            <input onblur="onBlur()" type="tel" id="input" placeholder="请输入11位手机号"/>
            <div id="btn" onclick="submit()">立即支付</div>
        </div>
        <div id="complete" class="body"
             style="display: none; flex-direction: row; margin-bottom: 25px; align-items: center">
            <div id="left-block"><span id="q-value" style="font-size: 30px; font-weight: 500"></span><span
                    id="q-type"></span>
            </div>
            <div id="right-block">
                <div id="q-name" style="font-size: 20px"></div>
                <div id="q-date" style="font-size: 12px; margin-top: 15px"></div>
            </div>
            <div id="btn-block" onclick="goto()">去使用</div>
        </div>
    </div>
</div>
<div id="modal">
    <div class="loading">
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
    </div>
</div>
<script>
  window.onload = function () {
    /**
     * 识别设备终端，获取app相关信息
     */
    window.terminal = (function () {
      const u = navigator.userAgent;//app = navigator.appVersion;
      return {//浏览器版本信息
        trident: u.indexOf('Trident') > -1,
        presto: u.indexOf('Presto') > -1,
        webKit: u.indexOf('AppleWebKit') > -1,
        gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') > -1,
        mobile: !!u.match(/AppleWebKit.*Mobile.*/),
        ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
        android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
        iPhone: u.indexOf('iPhone') > -1,
        iPad: u.indexOf('iPad') > -1,
        webApp: u.indexOf('Safari') > -1,
        weixin: u.indexOf('MicroMessenger') > -1 && u.replace(/.*(MicroMessenger\/[^\s]*).*/, "$1").replace("MicroMessenger/", "") || false,
        appVersion: u.indexOf('bocapp(') > -1 ? u.match(/bocapp\(\S+\)/)[0].slice(7, -1) : '3.0.0'
      };
    })();
    /**
     * APP版本号比较方法
     * @param (String) version1 版本号1，当前版本号
     * @param (String) version2 版本号2，要求最低版本号
     * @returns {Number} 判断版本号1是否高于版本号2，高于为1,等于为0,低于为-1
     */
    // APP当前版本号获取方法：window.terminal.appVersion
    window.versionCompare = function (version1, version2) {
      const v1 = version1.split('.');
      const v2 = version2.split('.');
      for (let i = 0; i < v1.length; i++) {
        if (v1[i] * 1 > v2[i] * 1) {
          return 1;  // 当前版本号大于要求最低版本号
        } else if (v1[i] * 1 < v2[i] * 1) {
          return -1; // 当前版本号小于要求最低版本号
        }
      }
      return 0; // 当前版本号等于要求最低版本号
    };
    /**
     * 引入cordova
     */
    const script = document.createElement('script');
    const pth = "https://ebsnew.boc.cn/bocphone/BocMerchant/"; // 生产环境
    // 外网环境直接引用生产地址即可，若需新增cordova方法，另行提供DMZ区地址
    if (window.terminal.iPhone) {
      script.src = pth + 'paylib/ios.js'
    } else if (window.terminal.android) {
      script.src = pth + 'paylib/android.js'
    } else {
      // alert('无法识别终端类型')
    }
    document.getElementsByTagName('head')[0].appendChild(script)
  };
</script>
</body>
</html>